Member Can be made Static (MCS)

Description:

MCS detects methods that can be made static .

Methods that do not access instance variables of the declaring class should be made static . Overridden methods and methods that may be designed to be overridden (virtual public and protected methods) are skipped because they cannot be static .

Incorrect:

public class IdGenerator {
    static int id;
    
    public int NextId() {
        return id++;
    }
}

Correct:

public class IdGenerator {
    static int id;
    
    public static int NextId() {
        return id++;
    }
}